package com.neusoft.neu24.controller;


import com.neusoft.neu24.Result.CommonResult;
import com.neusoft.neu24.dto.GridDTO;
import com.neusoft.neu24.dto.GridorDTO;
import com.neusoft.neu24.entity.Grid;
import com.neusoft.neu24.service.impl.GridServiceImpl;
import io.swagger.models.auth.In;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/grid")
public class GridController {

    @Resource
    private GridServiceImpl gridService;

    @GetMapping("/list")
    public CommonResult<List<GridDTO>> listAll(){
        return gridService.listAll2DTO();
    }

    @GetMapping("/fill")
    public CommonResult<List<Grid>> fillAllCities() {
        return CommonResult.success(gridService.fillContent());
    }

    @GetMapping("/relation")
    public CommonResult<List<Grid>> fillCityRelations() {
        return gridService.fillGridRelation();
    }

    @GetMapping("/ids/{id}")
    public CommonResult<List<Integer>> getIds(@PathVariable Integer id) {
        return gridService.getPids(id);
    }

    @GetMapping("/get/{id}")
    public CommonResult<Grid> getGrid(@PathVariable Integer id) {
        return gridService.getGrid(id);
    }

    @GetMapping("/gridors/{id}")
    public CommonResult<List<GridorDTO>> getGridorIds(@PathVariable Integer id) {
        return gridService.getGridors(id);
    }

    @GetMapping("/pids/{id}")
    public CommonResult<List<Integer>> getPidsById(@PathVariable Integer id) {
        return CommonResult.success(gridService.getPidsBySelect(id));
    }
}
